(function($){		
			$.fn.meetoo = function(options) {
				//test of Versions Program
				//Set main options
				var opts = $.extend({}, $.fn.meetoo.defaults,options);
				
				if(opts.debug) {
					tracer = opts;
				}
				
				var fullSet = jQuery.makeArray(this);
				var lastItem = fullSet[fullSet.length-1]; //.pop();
				var title = [];
				
				$(fullSet).each(function() {
					var iTitle = $(this).attr("title") || $(this).attr("alt") || $this.html();
					title.push(iTitle);												 
				});
				
				var first = true;
				//console.dir(title);
				
				return $(lastItem).each(function() {
					var $this = $(this);
					var $box = $('<div>Hello World</div>');
					
					// build element specific options
					var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
					
					
					
					var adPosition = $this.offset();
										
					//var title = $(this).attr("title") || $(this).attr("alt") || $this.html();
					
					 
					if (isOffscreen($this)) {
						var commonCSS = {
							opacity:0,
							backgroundColor:o.background,
							padding:"20px",
							color:o.color,
							height:o.height,
							width:o.width,
							visibility:(first)?"visible":"hidden"
						}
						if (!isCrapBrowser()) {							
							var myCss = {
								position:"fixed"
							}
							myCss = $.extend({}, myCss, o.position)
							//console.dir(myCss);
							
						} else {
							//your browser is crap. you should upgrade
							var myTop = (o.position.top) ? (o.position.top+$(window).scrollTop()) : "auto";
							var myRight = (o.position.right) ? (o.position.right) : "auto";
							var myLeft = (o.position.left) ? ($(window).scrollLeft()+o.position.left) : "auto";
							var myBottom = (o.position.bottom) ? (o.position.bottom) : "auto";
							
							var myCss = {
								position:"absolute",
								top: myTop,
								right: myRight,
								left: myLeft,
								bottom: myBottom
							}
							//myCss = $.extend({}, myCss, {});
						}
						
						$box.insertAfter($this).css(commonCSS).css(myCss)
						.click(function() {
							debug("width modifier:"+$(window).width()*.5);
							debug("adPosition: "+adPosition.left);
							var scrollLeft = adPosition.left-Math.floor($(window).width()*.5);
							var scrollTop = adPosition.top-Math.floor($(window).height()*.5);
							debug("scrollLeft value: "+scrollLeft);
							window.scrollTo(scrollLeft,scrollTop);
						})
						.html(o.boxTitle+formatTitles(title,o))
						.data("test",title)
						.animate({opacity:o.opacity}, o.fadeSlow, "", function(){
																								 
							o.timeoutPointer = setTimeout(function() {
								//debug($box.data("test"));
								removeBox($box, o.fadeSlow);
							}, o.timeout)																
						});
						watchScroll($box, $this, o);
					}
					
					first = false;
					
				});
				
			};
			
			$.fn.meetoo.boxPool = [];
								
			$.fn.meetoo.defaults = {
				boxTitle:"<h3 style='padding-top:0px; margin-top:0px;'>Check Out Some Special Offers Below</h3>",
				background:"#003366",
				color:"#ffffff",
				opacity:'1',
				height:"150px",
				width:"200px",
				listClass:"",
				timeout:10000,
				position:{right:100, bottom:30},
				debug:false,
				fadeFast:200,
				fadeSlow:1500
			};
			
			function watchScroll($obj, $ad, o) {
				$(window).bind('scroll.meeTooBox', function() {	
					if (!isOffscreen($ad)) {
							clearTimeout(o.timeoutPointer);
							removeBox($obj, o.fadeFast);						
					}
					
				});
				
				$.fn.meetoo.boxPool.push($obj);
				
				if (isCrapBrowser()) {
					var $left = $obj.offset().left-$(window).scrollLeft();
					var $top = $obj.offset().top-$(window).scrollTop();
					$(window)
						.bind('scroll.meeTooBox', function() {	
							calculateNewPosition($obj, $top, $left)
						})
						.bind('resize.meeTooBox', function(e) {
							//console.dir(e);
							calculateNewPosition($obj, $top, $left)																 
						});
					
					
				}
			}
			
			function removeBox($obj, speed) {
				$obj.stop().animate({opacity:0}, speed, "", function(){
					$obj.remove();
					$(window).unbind(".meeTooBox");
				});
				
				/*jQuery.each($.fn.meetoo.boxPool, function(){
						debug(this);
						this.stop().animate({opacity:0}, speed, "", function(){
							this.remove();
							$(window).unbind(".meeTooBox");
						});													
				});*/
				
				//$.fn.meetoo.boxPool = [];	
				
			}
			
			function isOffscreen($obj) {
					var offset = $obj.offset();
					var docHeight = $(document).height();
					var winHeight = $(window).height();
					var winWidth = $(window).width();
					
					var scrollOffsetLeft = $(window).scrollLeft();
					var scrollOffset = $(window).scrollTop();
					debug("object scrolltop ="+$(window).scrollTop());
					debug("object offset = "+offset.top);
					debug("document height = "+docHeight);
					debug("window height = "+winHeight);
					if((offset.top+$obj.height()>scrollOffset && offset.left+$obj.width()>scrollOffsetLeft) && (offset.top<scrollOffset+winHeight && offset.left<scrollOffsetLeft+winWidth)) {
						return false;
					} else {
						return true;
					}
			}
			
			function calculateNewPosition($obj, $top, $left) {
				var topOffset = $(window).scrollTop()+$top
				var leftOffset = $(window).scrollLeft()+$left;
				$obj.css({top:topOffset, left:leftOffset, bottom:"auto", right:"auto"});
			}
			
			function isCrapBrowser() {
					//return (jQuery.browser.msie && jQuery.browser.version < 7) ? true: false;
					return (jQuery.browser.msie) ? true: false;
			}
			
			function formatTitles(title, o) {
					var ftitle = "<ul class='"+o.listClass+"'>";
					jQuery.each(title,function(){
						ftitle += "<li>"+this+"</li>";													 
					});
					ftitle += "</ul>";
					
					return ftitle;
			}
					
			function debug($obj) {
				if (window.console && window.console.log) 
					window.console.log($obj);
					//window.console.dir($obj);
			};
			
					
})(jQuery);